home *** CD-ROM | disk | FTP | other *** search
/ Let's Discover Louisiana / Let's Discover Louisiana.iso / pc / FILES / FUND.dxr / 00075_Draggable.ls < prev    next >
Encoding:
Text File  |  2002-12-03  |  1.7 KB  |  76 lines

  1. property pSprite, pLocOffset, pActive, pConstrained
  2.  
  3. on beginSprite me
  4.   pSprite = sprite(me.spriteNum)
  5.   vMember = pSprite.member
  6.   case vMember.type of
  7.     #animGif, #flash, #quickTimeMedia, #digitalVideo, #vectorShape:
  8.       if vMember.directToStage then
  9.         alert("Sprite" && pSprite.spriteNum & ": Direct To Stage media may cause" && "playback problems with the 'Moveable Sprite' behavior.")
  10.       end if
  11.   end case
  12.   pActive = 0
  13. end
  14.  
  15. on mouseUp me
  16.   mDrag(0)
  17. end
  18.  
  19. on mouseDown me
  20.   mDrag(1)
  21. end
  22.  
  23. on prepareFrame me
  24.   if the mouseUp then
  25.     mDrag(0)
  26.   end if
  27.   if pActive then
  28.     mDragSprite(me)
  29.   end if
  30. end
  31.  
  32. on mDrag vActive
  33.   pActive = vActive
  34.   pLocOffset = pSprite.loc - the mouseLoc
  35.   sendAllSprites(#Active_Sprite, the currentSpriteNum * pActive)
  36. end
  37.  
  38. on mDragSprite
  39.   pSprite.loc = the mouseLoc + pLocOffset
  40.   if pConstrained then
  41.     vLeftDiff = pSprite.rect.left
  42.     if vLeftDiff < 0 then
  43.       pSprite.locH = pSprite.locH - vLeftDiff
  44.     end if
  45.     vRightDiff = pSprite.rect.right - (the stage).rect.width
  46.     if vRightDiff > 0 then
  47.       pSprite.locH = pSprite.locH - vRightDiff
  48.     end if
  49.     vTopDiff = pSprite.rect.top
  50.     if vTopDiff < 0 then
  51.       pSprite.locV = pSprite.locV - vTopDiff
  52.     end if
  53.     vBottomDiff = pSprite.rect.bottom - (the stage).rect.height
  54.     if vBottomDiff > 0 then
  55.       pSprite.locV = pSprite.locV - vBottomDiff
  56.     end if
  57.   end if
  58. end
  59.  
  60. on Forwarded_mouseDown me
  61.   if not pActive then
  62.     mDrag(1)
  63.   end if
  64.   return the currentSpriteNum
  65. end
  66.  
  67. on isOKToAttach me, aSpriteType, aSpriteNum
  68.   return aSpriteType = #graphic
  69. end
  70.  
  71. on getPropertyDescriptionList
  72.   vPDList = [:]
  73.   setaProp(vPDList, #pConstrained, [#comment: "Constrain to stage", #format: #boolean, #default: 1])
  74.   return vPDList
  75. end
  76.